package com.android.launcher3;

import android.app.Application;
import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;

import com.android.launcher3.util.DeviceUtils;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.UncaughtExceptionHandler;

public class LauncherApplication extends Application {
    private static LauncherApplication INSTANCE;
    private static Handler mHandler;

    public static LauncherApplication getInstance() {
        return INSTANCE;
    }

    public static Handler getMainHandler() {
        return mHandler;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        INSTANCE = this;
        mHandler = new Handler();
        DeviceUtils.logDeviceInfo(this);
        UncaughtExceptionHandler.catchCrash(this);
        setDefaultWallpaper();
    }

    private void setDefaultWallpaper() {
//        try {
//            WallpaperManager wm = (WallpaperManager) getSystemService(Context.WALLPAPER_SERVICE);
//            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.default_wallpaper);
//            wm.setBitmap(bitmap);
//            Logger.d(getClass(), "setDefaultWallpaper");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}
